﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using winproject;
using winproject.Models;
namespace winproject.Controllers
{
    public class HelperController : Controller
    {
        //
        // GET: /Helper/

        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// GetCategoryDetails:: get category details
        /// </summary>
        /// <param name="oResult"></param>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public List<CategoryDetails> GetCategoryDetails(out ReturnResult oResult, CategoryDetails oSearchItem = null)
        {
            oResult = null;
            CategoryModel oCatDetail = new CategoryModel();
            List<CategoryDetails> oItemDetailList = null;
            oResult = oCatDetail.getCategoryDetails(out oItemDetailList, oSearchItem);
            return oItemDetailList;
        }

        /// <summary>
        /// GetCategoryDetailsJSON:: get category details json
        /// </summary>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public JsonResult GetCategoryDetailsJSON(CategoryDetails oSearchItem = null)
        {
            ReturnResult oResult = null;
            List<CategoryDetails> oItemDetailList = null;
            oItemDetailList = GetCategoryDetails(out oResult, oSearchItem);
            return Json(oResult, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// GetSubCategoryDetails:: get subcategory details
        /// </summary>
        /// <param name="oResult"></param>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public List<SubCategoryDetails> GetSubCategoryDetails(out ReturnResult oResult, SubCategoryDetails oSearchItem = null)
        {
            oResult = null;
            SubCategoryModel oDetail = new SubCategoryModel();
            List<SubCategoryDetails> oItemDetailList = null;
            oResult = oDetail.getSubCategoryDetails(out oItemDetailList, oSearchItem);
            return oItemDetailList;
        }

        /// <summary>
        /// GetSubCategoryDetailsJSON :: get subcategory details json
        /// </summary>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public JsonResult GetSubCategoryDetailsJSON(SubCategoryDetails oSearchItem = null)
        {
            ReturnResult oResult = null;
            List<SubCategoryDetails> oItemDetailList = null;
            oItemDetailList = GetSubCategoryDetails(out oResult, oSearchItem);
            return Json(oResult, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// GetProductDetails:: get product details
        /// </summary>
        /// <param name="oResult"></param>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public List<ProductDetails> GetProductDetails(out ReturnResult oResult, ProductDetails oSearchItem = null)
        {
            oResult = null;
            ProductsModel oDetail = new ProductsModel();
            List<ProductDetails> oItemDetailList = null;
            oResult = oDetail.getProductDetails(out oItemDetailList, oSearchItem);
            return oItemDetailList;
        }

        /// <summary>
        /// GetProductDetailsJSON:: get product details JSON
        /// </summary>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public JsonResult GetProductDetailsJSON(ProductDetails oSearchItem = null)
        {
            ReturnResult oResult = null;
            List<ProductDetails> oItemDetailList = null;
            oItemDetailList = GetProductDetails(out oResult, oSearchItem);
            return Json(oResult, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// GetCurrencyDetails :: get currency details
        /// </summary>
        /// <param name="oResult"></param>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public List<CurrencyDetails> GetCurrencyDetails(out ReturnResult oResult, CurrencyDetails oSearchItem = null)
        {
            oResult = null;
            HelperModel oDetail = new HelperModel();
            List<CurrencyDetails> oItemDetailList = null;
            oResult = oDetail.getCurrencyDetails(out oItemDetailList, oSearchItem);
            return oItemDetailList;
        }

        /// <summary>
        /// GetCurrencyDetailsJSON :: get currency details json
        /// </summary>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public JsonResult GetCurrencyDetailsJSON(CurrencyDetails oSearchItem = null)
        {
            ReturnResult oResult = null;
            List<CurrencyDetails> oItemDetailList = null;
            oItemDetailList = GetCurrencyDetails(out oResult, oSearchItem);
            return Json(oResult, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// GetProductImages:: used to fetch product images
        /// </summary>
        /// <param name="oResult"></param>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public List<ProductImages> GetProductImages(out ReturnResult oResult, ProductImages oSearchItem = null)
        {
            oResult = null;
            ProductImagesModel oDetail = new ProductImagesModel();
            List<ProductImages> oItemDetailList = null;
            oResult = oDetail.getProdImages(out oItemDetailList, oSearchItem);
            return oItemDetailList;
        }

        /// <summary>
        /// GetProductImagesJSON:: used to fetch json of images uploaded for a product
        /// </summary>
        /// <param name="oSearchItem"></param>
        /// <returns></returns>
        public JsonResult GetProductImagesJSON(ProductImages oSearchItem = null)
        {
            ReturnResult oResult = null;
            List<ProductImages> oItemDetailList = null;
            oItemDetailList = GetProductImages(out oResult, oSearchItem);
            return Json(oResult, JsonRequestBehavior.AllowGet);
        }
    }
}
